import { createStore, combineReducers, applyMiddleware } from 'redux';
import userReducer from './user/userReducer';
import logger from 'redux-logger'
import { useSelector, TypedUseSelectorHook } from 'react-redux'
// 合并reducer
const reducer = combineReducers({
  user: userReducer
})
// 创建仓库
const store = createStore(reducer, applyMiddleware(logger));
// 获取仓库的类型
export type RootState = ReturnType<typeof store.getState>
// 重写 useSelector hooks， 方便获取仓库类型 
export const useAppSelector: TypedUseSelectorHook<RootState>  = useSelector
export default store

